package org.boulderfoodrescue.webapp.client.events;

import org.boulderfoodrescue.webapp.shared.RecurringEvent;

import com.google.gwt.event.shared.GwtEvent;

public class RecurringEventUpdatedEvent extends GwtEvent<RecurringEventUpdatedHandler>{
	private static final Type<RecurringEventUpdatedHandler> TYPE = new Type<RecurringEventUpdatedHandler>();
	private ChangeType changeType;
	private RecurringEvent recurringEvent;

	public RecurringEventUpdatedEvent(ChangeType changeType, RecurringEvent recurringEvent) {

		this.changeType = changeType;
		this.recurringEvent = recurringEvent;
	}

	public static Type<RecurringEventUpdatedHandler> getType() {
		return TYPE;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<RecurringEventUpdatedHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(RecurringEventUpdatedHandler handler) {
		switch(changeType)
		{
		case Added: handler.onRecurringEventAdded(this);break;
		case Removed: handler.onRecurringEventRemoved(this);break;
		case Updated: handler.onRecurringEventUpdated(this);break;
		}
	}

	public RecurringEvent getValue(){
		return recurringEvent;
	}
}
